package com.pierrepochon.RemoTxt.Services;

import java.util.Timer;
import java.util.TimerTask;

import com.pierrepochon.RemoTxt.Controller.GeneralRequestController;
import com.pierrepochon.RemoTxt.Controller.MessageToSendController;
import com.pierrepochon.RemoTxt.Params.Params;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;


public class RemoTxtService extends Service {

	Timer t = new Timer();
	
	@Override
	public IBinder onBind(Intent intent) {
		
		return null;
	}
	
	@Override
	public void onCreate() {
		super.onCreate();
		
        //chargement des parametres
        Params.loadAllParams(getApplicationContext());
        
		t = new Timer();
	}
	
	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
			
	    t.scheduleAtFixedRate(new TimerTask() {

	    	@Override
	        public void run() {
	    		GeneralRequestController grc = new GeneralRequestController(getApplicationContext());
	    		grc.execute(); 
	    		
	        } 
	    }, 0, 10000); 
	 
	    return START_NOT_STICKY; 
	}

		
}
